package com.victor.utils;

import java.util.List;
import java.util.Map;

/**
 * 通过手机号获取验证码 (将手机号和验证码放入list中 通过手机号获取验证码)
 * 
 * @author victor
 * 
 */
public class CodeUtil {

	/**
	 * mobile和random绑定存入list中
	 * 
	 * @param mmmlist
	 * @param mobile
	 * @return
	 */
	public static String getmapvalue(List<Map<String, Object>> codelist, String mobile) {
		String value = "";
		for (int i = 0; i < codelist.size(); i++) {
			Map<String, Object> codemap = codelist.get(i);
			if (mobile.equals(codemap.get("mobile").toString())) {
				value = codemap.get("random").toString();
			}
		}
		return value;
	}

	/**
	 * 
	 * @param mobile
	 */
	public static void clearothermap(List<Map<String, Object>> codelist, String mobile) {
		for (int i = 0; i < codelist.size(); i++) {
			Map<String, Object> codemap = codelist.get(i);
			if (mobile.equals(codemap.get("mobile").toString())) {
				codelist.remove(i);
			}
		}

	}
	
	/**
	 * mail和random绑定存入list中
	 * 
	 * @param mmmlist
	 * @param mobile
	 * @return
	 */
	public static String getMailmapvalue(List<Map<String, Object>> codelist, String mail) {
		String value = "";
		for (int i = 0; i < codelist.size(); i++) {
			Map<String, Object> codemap = codelist.get(i);
			if (mail.equals(codemap.get("mail").toString())) {
				value = codemap.get("random").toString();
			}
		}
		return value;
	}

	/**
	 * 
	 * @param mobile
	 */
	public static void clearMailothermap(List<Map<String, Object>> codelist, String mail) {
		for (int i = 0; i < codelist.size(); i++) {
			Map<String, Object> codemap = codelist.get(i);
			if (mail.equals(codemap.get("mail").toString())) {
				codelist.remove(i);
			}
		}

	}
}
